import 'package:faker/common/config.dart';
import 'package:faker/models/local_rss.dart';
import 'package:faker/utils/route_util.dart';
import 'package:faker/widgets/add_rss.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class TileCard extends StatelessWidget {
  final Rss rss;
  final int cardNo;

  TileCard({Key key, @required this.rss, @required this.cardNo})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        RouteUtil.push(
            context,
            AddRssScreen(
              editKey: 0,
              icon: "",
              rss: new LocalRss(
                  0,
                  0,
                  "",
                  rss.getName(),
                  rss.getDesc(),
                  rss.getAuth(),
                  rss.getRoute(),
                  rss.getParameter(),
                  rss.getExample(),
                  0,
                  ""),
            ));
      },
      child: Card(
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(10.0),
        ),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            ClipRRect(
              borderRadius: BorderRadius.circular(8.0),
              child: Image.asset(randomCardImg[cardNo]),
            ),
            Container(
              padding:
                  EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(20)),
              margin: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(10)),
              child: Text(
                rss.getName(),
                style: TextStyle(
                    fontSize: ScreenUtil().setSp(30),
                    fontWeight: FontWeight.bold),
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
              ),
            ),
            Container(
              margin: EdgeInsets.only(left: ScreenUtil().setWidth(20)),
              child: Text(
                rss.getDesc(),
                style: TextStyle(
                  fontSize: ScreenUtil().setSp(25),
                ),
              ),
            ),
            SizedBox(
              height: 20.0,
            ),
            Container(
              margin: EdgeInsets.only(left: ScreenUtil().setWidth(20)),
              child: Text(
                rss.getAuth() + '\r\n',
                style: TextStyle(
                  fontSize: ScreenUtil().setSp(25),
                ),
              ),
            ),
            Container(
              margin: EdgeInsets.only(left: ScreenUtil().setWidth(20)),
              child: Text(
                rss.getRoute() + '\r\n',
                style: TextStyle(
                  fontSize: ScreenUtil().setSp(25),
                ),
              ),
            ),
            Container(
              margin: EdgeInsets.only(left: ScreenUtil().setWidth(20)),
              child: Text(
                rss.getParameter().replaceAll(';', '\r\n'),
                style: TextStyle(
                  fontSize: ScreenUtil().setSp(25),
                ),
              ),
            ),
            SizedBox(
              height: 20.0,
            ),
          ],
        ),
      ),
    );
  }
}
